import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/view/Login'
import NotFound from '@/components/common/NotFound'
import Home from '@/components/Home'

import UserInfo from '@/components/view/user/UserInfo'
import UpdateUserInfo from '@/components/view/user/UpdateUserInfo'
import ListUser from '@/components/view/user/ListUser'
import FeeRecord from '@/components/view/user/FeeRecord'
import ListUserPatient from '@/components/view/user/ListUserPatient'

import Registered from '@/components/view/caseInfo/Registered'
import RegisteredList from '@/components/view/caseInfo/RegisteredList'
import CaseInfo from '@/components/view/caseInfo/CaseInfo'
import NucleicAcid from '@/components/view/caseInfo/NucleicAcid'
import Medicine from '@/components/view/caseInfo/Medicine'

import HealthInfo from '@/components/view/healthInfo/HealthInfo'
import HealthItem from '@/components/view/healthInfo/HealthItem'
import HealthInfoPrint from '@/components/view/healthInfo/HealthInfoPrint'


import Websocket from '@/components/view/user/Websocket'



Vue.use(Router)

const router = new Router({

  routes: [
    {
      path: '/login',
      component: Login,
      name: 'login',
      hidden: true, children: []
    },
    {
      path: '/404',
      component: NotFound,
      name: '',
      hidden: true, children: []
    },
    {
      path: '/systemManagement',
      component: Home,
      name: '主菜单',
      iconCls: 'el-icon-setting', // 图标样式class
      children: [
        {
          path: '/userInfo',
          component: UserInfo,
          name: '个人信息',
          hidden: true,
        },
        {
          path: '/updateUserInfo',
          component: UpdateUserInfo,
          name: '个人信息',
          hidden: true,
        },
        {
          path: '/ListUser',
          component: ListUser,
          name: '用户管理',
          userType: '0'
        },
        {
          path: '/ListUserPatient',
          component: ListUserPatient,
          name: '健康档案',
          userType: '1'
        },
        {
          path: '/FeeRecord',
          component: FeeRecord,
          name: '费用信息',
          userType: '4'
        },
        {
          path: '/Registered',
          component: Registered,
          name: '挂号管理',
          userType: '2'
        },
        {
          path: '/RegisteredList',
          component: RegisteredList,
          name: '挂号列表',
          userType: '2'
        },
        {
          path: '/CaseInfo',
          component: CaseInfo,
          name: '诊断管理',
          userType: '12'
        },
        {
          path: '/NucleicAcid',
          component: NucleicAcid,
          name: '核酸检测',
          userType: '2'
        },
        {
          path: '/Medicine',
          component: Medicine,
          name: '药品管理',
          userType: '4'
        },
        {
          path: '/HealthInfo',
          component: HealthInfo,
          name: '健康信息',
          userType: '12'
        },
        {
          path: '/HealthInfoPrint',
          component: HealthInfoPrint,
          name: '健康档案',
          hidden: true,
          userType: '3'
        },
        {
          path: '/HealthItem',
          component: HealthItem,
          name: '检查项目',
          userType: '4'
        },
        {
          path: '/Websocket',
          component: Websocket,
          name: '线上咨询',
          userType: '123'
        },
      ]
    }
  ]
})
/**
 * 路由拦截
 * 权限验证
 */
router.beforeEach((to, from, next) => {
  if (to.path == "/") {
    router.replace({
      path: '/login',
      query: {
        redirect: router.currentRoute.fullPath
      }
    });
  } else {
    next();
  }
})
export default router

